package com.bdcom.autotest.ui.gif;

import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.net.URI;
import java.net.URL;

import javax.imageio.ImageIO;

public class NMSImgFactory {

	
	public static URL getResourceURL(String str) throws Exception{
		
		URL resource = NMSImgFactory.class.getResource(str);
		
		return resource;
	}
	
	public static Image loadIcon(String str) throws Exception{
		return ImageIO.read(NMSImgFactory.class.getResourceAsStream(str) );
		
	}
	
	
	public static Image loadIconScale(String str , int w , int h ) throws Exception{
		BufferedImage read = ImageIO.read(NMSImgFactory.class
				.getResourceAsStream(str));
		int width = read.getWidth();
		int height = read.getHeight();
		if (w == width && h == height) {
			return read;
		} else {
			Image image = read.getScaledInstance(w, h, Image.SCALE_DEFAULT);
//			BufferedImage img = new BufferedImage(w, w, Transparency.TRANSLUCENT);
//			Graphics graphics = img.getGraphics();

			return image;
		}
	}
	
	
	public static URI getServerLogo(){
		File file = new File("NMSWebres/resources/imgs/logo.png");
		return file.toURI();
	}
	
}
